package com.myadapter;

import java.util.ArrayList;

import com.bean.ZXfeeds;
import com.example.lizhiinformation.R;
import com.tools.ImageLoader;
import com.tools.Path_URL;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ZhenXiangDiadapter extends BaseAdapter {
	private ArrayList<ZXfeeds> list;
	private Context context;
	private View view;
	private LayoutInflater inflater;
	
	public ZhenXiangDiadapter(ArrayList<ZXfeeds> list, Context context,View view) {
		super();
		this.list = list;
		this.context = context;
		this.view=view;
		inflater = LayoutInflater.from(context);
	}
	public void addData(ArrayList<ZXfeeds> List){
		this.list.addAll(List);
		notifyDataSetChanged();
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public String getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0).getOid();
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stubl
		ViewHolder holder;
		if(arg1==null){
			arg1=inflater.inflate(R.layout.zhengxiangdi_items, null);
			holder=new ViewHolder();
			holder.imageView=(ImageView) arg1.findViewById(R.id.zhenxiangdiimage);
			holder.truth=(TextView) arg1.findViewById(R.id.truth);
			holder.rumor=(TextView) arg1.findViewById(R.id.rumor);
			arg1.setTag(holder);
		}else {
			holder=(ViewHolder) arg1.getTag();
		}
		holder.rumor.setText(list.get(arg0).getData().getSubject());
		holder.truth.setText(list.get(arg0).getData().getTruth());
		ImageLoader.cachr(context, Path_URL.IMAGEURL+list.get(arg0).getData().getCover(), holder.imageView,view);
		return arg1;
	}
	class ViewHolder{
		private ImageView imageView;
		private TextView rumor;
		private TextView truth;
	}

}
